-- magic_stone
-- created by panyl
-- 地牢格子：石柱

return {
    restoreGrid = function(grid, info)
        if info.magic_stone then
            local magic_stone = info.magic_stone;

            magic_stone["pos"] = grid:getPos();

            ME.user.dbase:setTemp("magic_stone", magic_stone);

            grid.id = magic_stone["id"];
        end
    end,

    -- 收集上下文
    collectContext = function(grid)
        local ret = {};

        ret.magic_stone = ME.user.dbase:queryTemp("magic_stone");
        return ret;
    end,

    -- 自动战斗
    autoFight = function(grid)
        if MagicStoneM.checkClosed() then
            -- 关闭石柱
            return DungeonActionM.go("closed_stone", ME.user.dbase:queryTemp("magic_stone", "pos", false));
        else
            -- 学习技能
            return DungeonActionM.go("study_stone");
        end
    end
};
